<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //闭包实现：a()输出1 在a()输出2 a()输出3 以此类推

        let a = (function() {
            let count = 0
            return function() {
                return ++count;

            }
        })()
        console.log(a());
        console.log(a());
        console.log(a());
    </script>
</body>

</html>